<?php
$jours = array("Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi");

if (isset($_GET['week']))
{
	$week = $_GET['week'] + 32;
	if ($week > 52) $week -= 52;
	for ($i = 1; $i<6; $i++)
	{
		$annee = ($week<35)? date('Y')+1 : date('Y');
		$class = "";
		if ((date('w') == $i && $week == date('W')) || ($week == date('W')+1 && (date('w') == 0 || date('w') == 6) && $i == 1 ))
			$class = "jour_rouge";
		echo "<div class=\"jour $class\">".$jours[$i-1]." ".trouver_date($week,$annee,$i)."</div>";
	}
}

function trouver_date($sem, $annee, $j)
{
	$jour_dans_le_mois = array();
	$mois = 1;
	$jour = 0;
	
	for($a=1;$a<=365+date('L');$a++)
	{ 
	for($i=1;$i<=12;$i++)
	{ 
		$jour += date('t', mktime(0, 0, 0, $i, 1, date('Y')));
		$jour_dans_le_mois[$i] = $jour;           
	} 
			 
	$today = mktime(0, 0, 0, $mois, $a, date('Y'));        
	$semaine = date('W', $today);
	$day = date('N', $today);
	$date = date('d/m/Y', $today);
	if(in_array($a, $jour_dans_le_mois)) $mois++;
			 
	if($semaine == $sem && $day == $j)
		return $date;
	}
}
?>